class monomeMod extends Mod
{
  monomeMod(Mod tempParent, float tempBx, float tempBy, int tempIndex){
    super(tempParent,tempBx,tempBy,tempIndex);
    img="mon";
    loadImg(img);
    name="monome";
    minWx=60;
    minWy=64;
    iPs[ip]=new inPort(this,1,"osc");
    oPs[op]=new outPort(this,2,"col");
    oPs[op]=new outPort(this,2,"row");
    oPs[op]=new outPort(this,2,"press");
    updatePorts();
  }

  void go(){
    String[] tokens=splitTokens(iPs[0].stringV, " /");
    //println(tokens);
    if(tokens[0].equals(":")){
      //serial
      sendFloat(float(int(tokens[2]) & 15),0);
      sendFloat(float(int(tokens[2]) >> 4),1);
      sendFloat(float(int(tokens[1])),2);

    }else{
      //osc
      if(tokens[0].equals("press")){
        for(int i=0;i<oPs[0].ws;i++){
          sendFloat(float(tokens[1]),0);

        }
        for(int i=0;i<oPs[1].ws;i++){
          sendFloat(float(tokens[2]),1);
        }
        for(int i=0;i<oPs[2].ws;i++){
          sendFloat(float(tokens[3]),2);
        }



      }
    }
  }
}

class monomeLEDMod extends Mod
{
  monomeLEDMod(Mod tempParent, float tempBx, float tempBy, int tempIndex){
    super(tempParent,tempBx,tempBy,tempIndex);
    img="led";
    loadImg(img);
    name="led";
    minWx=48;
    minWy=64;
    oPs[op]=new outPort(this,1,"osc");
    iPs[ip]=new inPort(this,2,"col");
    iPs[ip]=new inPort(this,2,"row");
    iPs[ip]=new inPort(this,2,"prs");
    updatePorts();
  }

  void go(){
    String out="/led "+(int)iPs[0].floatV+" "+(int)iPs[1].floatV+" "+(int)iPs[2].floatV;
    sendString(out, 0);

  }
}

class monomeLEDRowMod extends Mod
{
  monomeLEDRowMod(Mod tempParent, float tempBx, float tempBy, int tempIndex){
    super(tempParent,tempBx,tempBy,tempIndex);
    img="row";
    loadImg(img);
    name="led";
    minWx=50;
    minWy=50;
    oPs[op]=new outPort(this,1,"osc");
    iPs[ip]=new inPort(this,2,"row");
    iPs[ip]=new inPort(this,2,"value");
    updatePorts();

  }

  void go(){
    String out="/led_row "+(int)iPs[0].floatV+" "+(int)iPs[1].floatV;
    sendString(out, 0);

  }
}

class monomeLEDColMod extends Mod
{
  monomeLEDColMod(Mod tempParent, float tempBx, float tempBy, int tempIndex){
    super(tempParent,tempBx,tempBy,tempIndex);
    img="col";
    loadImg(img);
    name="led";
    minWx=50;
    minWy=50;
    oPs[op]=new outPort(this,1,"osc");
    iPs[ip]=new inPort(this,2,"col");
    iPs[ip]=new inPort(this,2,"value");
    updatePorts();

  }

  void go(){
    String out="/led_col "+(int)iPs[0].floatV+" "+(int)iPs[1].floatV;
    sendString(out, 0);

  }
}


